Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the C struct defined below:struct da... Start Learning for Free
Consider the C struct defined below:
struct data {
int marks [100];
char grade;
int cnumber;
};
struct data student;
The base address of student is available in register R1. The field student.grade can be accessed efficiently using
  • a)
    Post-increment addressing mode, (R1)+
  • b)
    Pre-decrement addressing mode, -(R1)
  • c)
    Register direct addressing mode, R1
  • d)
    Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Consider the C struct defined below:struct data {int marks [100];char ...
Option (D)
Displacement Mode :-
Similar to index mode, except instead of a index register a base register will be used. Base register contains a pointer to a memory location. An integer (constant) is also referred to as a displacement. The address of the operand is obtained by
adding the contents of the base register plus the constant. The difference between index mode and displacement mode is in the number of bits used to represent the constant. When the constant is represented a number of bits to access the
memory, then we have index mode. Index mode is more appropriate for array accessing; displacement mode is more appropriate for structure (records) accessing.
View all questions of this test
Most Upvoted Answer
Consider the C struct defined below:struct data {int marks [100];char ...
Understanding the Struct Layout
The struct defined has a layout as follows:
- `int marks[100];` - occupies 400 bytes (assuming 4 bytes per int).
- `char grade;` - occupies 1 byte.
- `int cnumber;` - occupies 4 bytes.
Total size = 400 + 1 + 4 = 405 bytes.
Accessing the Fields
Given that the base address of the struct `student` is stored in register R1, we can access the fields using different addressing modes.
Field Accessing Options
1. Post-increment addressing mode, (R1)+
- This mode increments the address after the access. It is not efficient for accessing specific fields.
2. Pre-decrement addressing mode, -(R1)
- This mode decrements the address before accessing. Again, it does not directly point to the grade field.
3. Register direct addressing mode, R1
- This mode accesses the address directly in R1. However, it does not specify the offset for the `grade` field.
4. Index addressing mode, X(R1)
- This mode allows access to any field by specifying an offset (X) from the base address in R1.
Efficient Access to `student.grade`
- The `grade` field is located at the offset of 400 bytes from the base address (R1).
- In index addressing mode, an offset can be represented in 2’s complement format, making it flexible for direct access.
Conclusion
Thus, the most efficient way to access `student.grade` is using option D (Index addressing mode, X(R1)), where X can be set to 400, representing the exact position of the grade field within the struct.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer?
Question Description
Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer?.
Solutions for Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer?, a detailed solution for Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the C struct defined below:struct data {int marks [100];char grade;int cnumber;};struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently usinga)Post-increment addressing mode, (R1)+b)Pre-decrement addressing mode, -(R1)c)Register direct addressing mode, R1d)Index addressing mode, X(R1), where X is an offset represented in 2's complement 16-bit representation.Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev